using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entites;
using DAL;
namespace BUS
{
   public class CTDiaDiemBUS
    {
        
         public static void Insert(CTDiaDiem ctdd)
        {
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
           ctddDAL.Insert(ctdd);
        }
        public static void Update(CTDiaDiem ctdd)
        {
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
            ctddDAL.Update(ctdd);
        }
        public static void Delete(int iD)
        {
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
            ctddDAL.Delete(iD);
        }
        public static tbCTDiaDiemCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
            return ctddDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbCTDiaDiemCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
            return ctddDAL.Get(cri.Criter, 0, 0, tbCTDiaDiemColumns.MaDD.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static CTDiaDiem GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbCTDiaDiemColumns.MaDD.ToString(), Condition.EQUAL, iD);
           CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
           tbCTDiaDiemCollection chitietdiadiemcollection = ctddDAL.Get(cri.Criter,
                 0, 0, tbCTDiaDiemColumns.MaDD.ToString(), OrderDirection.ASC.ToString(), out total);
           if (chitietdiadiemcollection.Count > 0)
               return chitietdiadiemcollection[0];
           return null;
       }
      
        public static tbCTDiaDiemCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
            return ctddDAL.Get(cri.Criter, 1, number,
             tbCTDiaDiemColumns.MaDD.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbCTDiaDiemCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            CTDiaDiemDAL ctddDAL = new CTDiaDiemDAL();
            return ctddDAL.Get(cri.Criter, 1, number,
               tbCTDiaDiemColumns.MaDD.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    
    
    
}
